package edu.qd.learn.newchapter.chapter03.work;


import java.time.LocalDate;

/**
 * 链式
 *
 * @author 布衣
 */
public class NoteBookLink implements NoteBook {

    //头指针
    Node head;

    Node tail;

    /**
     * 添加事件
     *
     * @param event
     */
    public void addEvent(Event event) {
        if (head == null) {
            head = new Node(event);
            tail = head;
            return;
        }

        Node temp = new Node(event);
        tail.next = temp;
        temp.prev = tail;
        tail = tail.next;
    }

    public void addEvent(String title, LocalDate data, String content) {
        addEvent(new Event(title, data, content));
    }

    /**
     * 打印 列表
     */
    public void list() {
        Node temp = head;
        while (temp != null) {
            System.out.println(temp.event);
            temp = temp.next;
        }
    }

    public class Node {
        Node prev;
        Event event;
        Node next;

        public Node(Event event) {
            this.event = event;
        }
    }


    public static void main(String[] args) {
        NoteBook noteBook = new NoteBookVector();
        noteBook.addEvent(new Event("title", LocalDate.now(), "content"));
        noteBook.list();
    }

}
